PROJECT HURST

We have defined our functions used in this project in " utils.py " : In order to look at the detail code of the Customized functions please see:

We kept the custom functions in a seperate file in order to keep the core code as clean as possible.

Method 1 (Ex-Post Orientation)

This Method has an Ex-Post Orientation. Basically R/S method was devised to estimate the Hurst Value over an Interval. Thus in this method, we will attempt to estimate Hurst Value over an interval by looking back at the series.

Based on the length of the series. We will first divide the series in intervals of equal length. Then we will determine the HURST VALUE over that entire Interval. Based on Hurst Value, we will employ Moving Average cross over strategy to generate a LONG/SHORT signal depending on whether the entire interval is Trending or Mean reverting.

EMA Crossover strategy over an interval based on Hurst Value:

In this strategy we first estimate the Hurst value over an interval by dividing the whole series into equal length – (3-4 months of Data points). We then compute short and long Exponential Moving Averages over that interval. Then based on Hurst value we will generate long or short signal depending on where the small and big Moving averages are:

Case 1: If Hurst Value is greater than 0.5, then our series will be Trending. In that case if the shorter moving average crosses the longer moving average from below. We will take long position. Similarly, if the shorter moving average crosses the longer moving average from above. We will take a short position.

Case 2: If Hurst Value is less than 0.5, then our series will be Mean-Reverting. This essentially means that a value higher than the mean is like to reverse or revert towards its mean in the future. Hence, we will reverse our moving average signal in this case: for instance, if the shorter moving average crosses the longer moving average from below, we will take a short position and vice versa.

We will test this strategy using “Bt” package in Python. We will compare the Total Return, CAGR (Compound Annual Growth Rate) and Sharpe ratio generated from this strategy with the passive “Buy and Hold” Strategy. We will assert that “EMA Crossover with Hurst” is a better strategy then passive “Buy and Hold” if we get better performance metrics.

Implementing Strategies

Bitcoin

S&P 500

HANG SENG

MSCI FRONTIER MARKETS

Benchmark Buy and Hold Strategy

METHOD 2: (EX-ANTE ORIENTATION)- "ROLLING HURST METHODOLOGY"

Moving Hurst

We initially estimated the rolling prices of the individual assets' closing prices over 128-day intervals. The hurst exponent function was then applied to each rolling window, and the resulting statistic was dubbed "rolling hurst" or "moving hurst."

To determine the trade signal, we used a Moving Average Convergence Divergence (MACD) Technical indicator on our moving hurst statistic. We substituted the price data with moving hurst data instead of utilizing asset prices to generate the MACD.

The difference between the 9-day exponentially weighted moving average and the 26-day exponentially weighted moving average is used to calculate the MACD. Similarly, the 9-day day exponentially weighted moving average was used to calculate the signal.

We selected three positions: buy, hold, and sell. A buy is signified by a signal of 1, a sell by a signal of -1, and a hold by not taking any action.

A buy position was taken anytime the MACD at a certain point in time was greater than the signal, while a sell position was taken in the opposite case. We opted to hold in all other cases.

Finally, we utilised the "bt" back testing library to evaluate the performance of our model.

First we will plot our Financial Time Series alongwith MACD

Here we will plot our MACD signal along with Hurst signal to determine Long/Short position

Now we will test the strategy with Bt package

Here we will display the Return profile of our Rolling Hurst strategy

Here we will implement Machine Learning Strategy

Histogram Gradient Boosting Classifier Model

We began by developing several features based on the closing pricing. We computed the statistics listed below.

• EMA10gtEMA30: The difference between the 10-day exponentially weighted moving average and the 30-day exponentially weighted moving average. A positive integer is assigned the value 1 and a negative number is assigned the value -1.

• ClGtEMA10: The difference between the close and the 10-day exponentially weighted moving average. A positive integer is assigned the value 1 and a negative number is assigned the value -1.

• MACD: Moving average convergence divergence (MACD) is a trend-following momentum indicator that depicts the connection between two moving averages of the price of a security. The MACD is derived by subtracting the exponential moving average (EMA) of 26 periods from the EMA of 12 periods. The MACD line is the outcome of the computation. The "signal line," a nine-day EMA of the MACD displayed on top of the MACD line, can therefore operate as a trigger for buy and sell signals.

• RSI: The relative strength index (RSI) is a momentum indicator used in technical analysis that examines the magnitude of recent price fluctuations to determine if a stock or other asset is overbought or oversold. The RSI is shown as an oscillator (a line graph that fluctuates between two extremes) and has a range of 0 to 100.

• Stochastic Oscillator: A stochastic oscillator is a momentum indicator that compares a security's closing price to a range of its prices over a given time-period. The oscillator's sensitivity to market changes can be reduced by altering the time-period or by taking a moving average of the result. It is used to create overbought and oversold trading signals with a 0–100 value range.

• William's Percentage Range: The indicator tells a trader where the current price is in relation to the maximum high in the previous 14 periods (or whatever number of lookback periods is chosen). When the indicator is between -20 and zero, the price is overbought or close to the peak of its most recent price range.

We use an increase in daily return as a positive indicator(target) for our machine learning model, assigning a value of 1 for each gain and -1 for each decrease.

Using the train test split function, we split the data into training and test sets, ensuring that the data is split chronologically by setting the shuffle argument to False.

After that, we chose a gradient boosting model, which is an ensemble model of the decision tree families. These models are known to be the most effective at predicting stock price direction. The Histogram Gradient Boosting Classifier model is the one we went with.

To find the best parameters for our classification model, we first ran a grid search cross validation. The maximum depth of each tree in the node and the maximum number of iterations for the ensemble model were the factors we investigated.

We fitted our HistGradientBoostingClassifier model with these parameters after our algorithm determined the ideal values. We used the training samples to train the model.

We then used the test features to make our predictions. For a buy signal, the model predicts 1 and for a sell signal, it predicts -1.

Finally, we evaluated our model's performance using the "bt" back testing library.

Results from our ML STRATEGY